home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / source / scout_cat.c < prev    next >
C/C++ Source or Header  |  2002-09-16  |  14KB  |  422 lines

  1. /****************************************************************
  2.    This file was created automatically by `FlexCat 2.6'
  3.    from "Scout.cd".
  4.  
  5.    Do NOT edit by hand!
  6. ****************************************************************/
  7.  
  8. /****************************************************************
  9.     This file uses the auto initialization possibilities of
  10.     Dice, gcc and SAS/C, respectively.
  11.  
  12.     Dice does this by using the keywords __autoinit and
  13.     __autoexit, SAS uses names beginning with _STI or
  14.     _STD, respectively. gcc uses the asm() instruction,
  15.     to emulate C++ constructors and destructors.
  16.  
  17.     Using this file you don't have *all* possibilities of
  18.     the locale.library. (No Locale or Language arguments are
  19.     supported when opening the catalog. However, these are
  20.     *very* rarely used, so this should be sufficient for most
  21.     applications.
  22. ****************************************************************/
  23.  
  24.  
  25. /*
  26.     Include files and compiler specific stuff
  27. */
  28. #include <exec/memory.h>
  29. #include <libraries/locale.h>
  30. #include <libraries/iffparse.h>
  31.  
  32. #include <proto/exec.h>
  33. #include <proto/dos.h>
  34. #include <proto/locale.h>
  35. #include <proto/utility.h>
  36. #include <proto/iffparse.h>
  37.  
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41.  
  42.  
  43. #include "Scout_cat.h"
  44.  
  45.  
  46. /*
  47.     Variables
  48. */
  49. struct FC_String Scout_Strings[171] = {
  50.     { (STRPTR) "Can't open input.device!\n", 0 },
  51.     { (STRPTR) "Can't open timer.device!\n", 1 },
  52.     { (STRPTR) "No HOST specified!\n", 2 },
  53.     { (STRPTR) "Please start a TCP/IP stack first (i.e. AmiTCP/Genesis or Miami(Dx))!\n", 3 },
  54.     { (STRPTR) "Can't create application!\n", 4 },
  55.     { (STRPTR) "Can't send script %s to port \"%s\"!\n", 5 },
  56.     { (STRPTR) "***Break\n", 6 },
  57.     { (STRPTR) "Can't initialize TCP/IP stack!\n", 100 },
  58.     { (STRPTR) "Password:", 101 },
  59.     { (STRPTR) "Can't get password!\n", 102 },
  60.     { (STRPTR) "Can't connect to server!\n", 103 },
  61.     { (STRPTR) "Can't create socket!\n", 104 },
  62.     { (STRPTR) "Can't find host \"%s\"!\n", 105 },
  63.     { (STRPTR) "Unknown option", 106 },
  64.     { (STRPTR) "Wrong password!\n", 107 },
  65.     { (STRPTR) "You don't have root privileges!\n", 108 },
  66.     { (STRPTR) "Unknown user!\n", 109 },
  67.     { (STRPTR) "No \"BEGIN\" received!\n", 110 },
  68.     { (STRPTR) "Error occured!", 111 },
  69.     { (STRPTR) "Continue", 112 },
  70.     { (STRPTR) "_Continue", 200 },
  71.     { (STRPTR) "\033c\n"\
  72.     "%s\n"\
  73.     "%s\n"\
  74.     "\n"\
  75.     "%s\n"\
  76.     "All Rights Reserved\n"\
  77.     "\n"\
  78.     "This program is \033bFreeware\033n.\n"\
  79.     "EMail: %s\n"\
  80.     "\n"\
  81.     "ARexx port name: %s\n", 201 },
  82.     { (STRPTR) "_Update", 300 },
  83.     { (STRPTR) "Pr_int", 301 },
  84.     { (STRPTR) "_Remove", 302 },
  85.     { (STRPTR) "_Priority", 303 },
  86.     { (STRPTR) "_More", 304 },
  87.     { (STRPTR) "_Close", 305 },
  88.     { (STRPTR) "E_xit", 306 },
  89.     { (STRPTR) "_Functions", 307 },
  90.     { (STRPTR) "Yes|No", 308 },
  91.     { (STRPTR) "Once|All|Cancel", 309 },
  92.     { (STRPTR) "_Ok", 310 },
  93.     { (STRPTR) "_Cancel", 311 },
  94.     { (STRPTR) "<none>", 312 },
  95.     { (STRPTR) "Do you really want to remove directory\n"\
  96.     "\"%s\" from assign \"%s\"?", 400 },
  97.     { (STRPTR) "Do you really want to assign \"%s\"?", 401 },
  98.     { (STRPTR) "Do you really want to remove class\n"\
  99.     "\"%s\"?", 500 },
  100.     { (STRPTR) "Can't remove INTERNAL commands!", 600 },
  101.     { (STRPTR) "Can't remove SYSTEM commands!", 601 },
  102.     { (STRPTR) "Can't remove DISABLED commands!", 602 },
  103.     { (STRPTR) "Do you really want to remove command\n"\
  104.     "\"%s\"?", 603 },
  105.     { (STRPTR) "_Appear", 700 },
  106.     { (STRPTR) "_Disappear", 701 },
  107.     { (STRPTR) "_Enable", 702 },
  108.     { (STRPTR) "Di_sable", 703 },
  109.     { (STRPTR) "_Kill", 704 },
  110.     { (STRPTR) "List_Chg", 705 },
  111.     { (STRPTR) "Uni_que", 706 },
  112.     { (STRPTR) "Do you really want to remove commodity\n"\
  113.     "\"%s\"?", 707 },
  114.     { (STRPTR) "Do you really want to remove device\n"\
  115.     "\"%s\"?", 800 },
  116.     { (STRPTR) "Supported commands:", 801 },
  117.     { (STRPTR) "[identify.library required]", 900 },
  118.     { (STRPTR) "Do you really want to close font\n"\
  119.     "\"%s\"?", 1000 },
  120.     { (STRPTR) "Do you really want to remove font\n"\
  121.     "\"%s\"?", 1001 },
  122.     { (STRPTR) "Sorry, the count of accessors is already zero!", 1002 },
  123.     { (STRPTR) "Sorry, the count of accessors is not zero!", 1003 },
  124.     { (STRPTR) "<no .fd file>", 1100 },
  125.     { (STRPTR) "<no jmp>", 1101 },
  126.     { (STRPTR) "<no entry in .fd file>", 1102 },
  127.     { (STRPTR) "Do you really want to remove input handler\n"\
  128.     "\"%s\"?", 1200 },
  129.     { (STRPTR) "Sorry, I can't remove an interrupt handler!", 1300 },
  130.     { (STRPTR) "Do you really want to remove interrupt server\n"\
  131.     "\"%s\"?", 1301 },
  132.     { (STRPTR) "Do you really want to remove library\n"\
  133.     "\"%s\"?", 1400 },
  134.     { (STRPTR) "Do you really want to close library\n"\
  135.     "\"%s\"?", 1401 },
  136.     { (STRPTR) "Sorry, the open count is already zero!", 1402 },
  137.     { (STRPTR) "Pattern:", 1500 },
  138.     { (STRPTR) "%lD shown, %lD hidden", 1501 },
  139.     { (STRPTR) "%lD shown, %lD hidden. Done.", 1502 },
  140.     { (STRPTR) "Do you really want to remove lock\n"\
  141.     "\"%s\"?", 1503 },
  142.     { (STRPTR) "Yes|All|No|Abort", 1504 },
  143.     { (STRPTR) "Do you really want to remove lowmemory handler\n"\
  144.     "\"%s\"?", 1600 },
  145.     { (STRPTR) "dummy", 1700 },
  146.     { (STRPTR) "read only", 1800 },
  147.     { (STRPTR) "validating", 1801 },
  148.     { (STRPTR) "read/write", 1802 },
  149.     { (STRPTR) "no disk", 1803 },
  150.     { (STRPTR) "unreadable", 1804 },
  151.     { (STRPTR) "Do you really want to remove port\n"\
  152.     "\"%s\"?", 1900 },
  153.     { (STRPTR) "Change priority", 2000 },
  154.     { (STRPTR) "Min:", 2001 },
  155.     { (STRPTR) "Max:", 2002 },
  156.     { (STRPTR) "Old:", 2003 },
  157.     { (STRPTR) "New:", 2004 },
  158.     { (STRPTR) "\033c Please select a new priority for \n"\
  159.     "\"%s\"", 2005 },
  160.     { (STRPTR) "dummy", 2100 },
  161.     { (STRPTR) "Do you really want to remove resource\n"\
  162.     "\"%s\"?", 2200 },
  163.     { (STRPTR) "MCOMPAT_MIXED: can share display with other MIXED", 2300 },
  164.     { (STRPTR) "MCOMPAT_SELF: can share only within monitor", 2301 },
  165.     { (STRPTR) "MCOMPAT_NOBODY: only one viewport", 2302 },
  166.     { (STRPTR) "_Obtain", 2400 },
  167.     { (STRPTR) "Re_lease", 2401 },
  168.     { (STRPTR) "Do you really want to obtain semaphore\n"\
  169.     "\"%s\"?", 2402 },
  170.     { (STRPTR) "Do you really want to release semaphore\n"\
  171.     "\"%s\"?", 2403 },
  172.     { (STRPTR) "Sorry, the semaphore's nest count is already zero!", 2404 },
  173.     { (STRPTR) "Do you really want to remove semaphore\n"\
  174.     "\"%s\"?", 2405 },
  175.     { (STRPTR) "Send signal", 2500 },
  176.     { (STRPTR) "Signal:", 2501 },
  177.     { (STRPTR) "SigWait:", 2502 },
  178.     { (STRPTR) "\033c Please select the signal for \n"\
  179.     "\"%s\"", 2503 },
  180.     { (STRPTR) "dummy", 2600 },
  181.     { (STRPTR) "_Freeze", 2700 },
  182.     { (STRPTR) "_Activate", 2701 },
  183.     { (STRPTR) "_Signal", 2702 },
  184.     { (STRPTR) "_Break", 2703 },
  185.     { (STRPTR) " Secs:", 2704 },
  186.     { (STRPTR) "off", 2705 },
  187.     { (STRPTR) "full", 2706 },
  188.     { (STRPTR) "in %", 2707 },
  189.     { (STRPTR) "Do you really want to remove %s\n"\
  190.     "\"%s\"?", 2708 },
  191.     { (STRPTR) "Also remove ports, window, etc allocated by task\n"\
  192.     "\"%s\"?", 2709 },
  193.     { (STRPTR) "Sorry, I can't find that task!", 2710 },
  194.     { (STRPTR) "Can't install patch semaphore!", 2711 },
  195.     { (STRPTR) "Found old patch semaphore (V%ld.%ld)!\n"\
  196.     "I will replace this one by a new one (V%ld.%ld)!", 2712 },
  197.     { (STRPTR) "<no task>", 2713 },
  198.     { (STRPTR) "frozen", 2714 },
  199.     { (STRPTR) "added", 2715 },
  200.     { (STRPTR) "running", 2716 },
  201.     { (STRPTR) "ready", 2717 },
  202.     { (STRPTR) "waiting", 2718 },
  203.     { (STRPTR) "wait abort", 2719 },
  204.     { (STRPTR) "wait child", 2720 },
  205.     { (STRPTR) "wait sema", 2721 },
  206.     { (STRPTR) "wait intui", 2722 },
  207.     { (STRPTR) "wait net", 2723 },
  208.     { (STRPTR) "wait dos", 2724 },
  209.     { (STRPTR) "wait break C", 2725 },
  210.     { (STRPTR) "wait break D", 2726 },
  211.     { (STRPTR) "wait break E", 2727 },
  212.     { (STRPTR) "wait break F", 2728 },
  213.     { (STRPTR) "suspended", 2729 },
  214.     { (STRPTR) "except", 2730 },
  215.     { (STRPTR) "removed", 2731 },
  216.     { (STRPTR) "invalid", 2732 },
  217.     { (STRPTR) "< ??? >", 2733 },
  218.     { (STRPTR) "task", 2734 },
  219.     { (STRPTR) "interrupt", 2735 },
  220.     { (STRPTR) "device", 2736 },
  221.     { (STRPTR) "msgport", 2737 },
  222.     { (STRPTR) "message", 2738 },
  223.     { (STRPTR) "freemsg", 2739 },
  224.     { (STRPTR) "replymsg", 2740 },
  225.     { (STRPTR) "resource", 2741 },
  226.     { (STRPTR) "library", 2742 },
  227.     { (STRPTR) "memory", 2743 },
  228.     { (STRPTR) "softint", 2744 },
  229.     { (STRPTR) "font", 2745 },
  230.     { (STRPTR) "process", 2746 },
  231.     { (STRPTR) "semaphore", 2747 },
  232.     { (STRPTR) "signalsem", 2748 },
  233.     { (STRPTR) "bootnode", 2749 },
  234.     { (STRPTR) "kickmem", 2750 },
  235.     { (STRPTR) "graphics", 2751 },
  236.     { (STRPTR) "deathmessage", 2752 },
  237.     { (STRPTR) "user", 2753 },
  238.     { (STRPTR) "extended", 2754 },
  239.     { (STRPTR) "unknown", 2755 },
  240.     { (STRPTR) "< ??? >", 2756 },
  241.     { (STRPTR) "dummy", 2800 },
  242.     { (STRPTR) "dummy", 2900 },
  243.     { (STRPTR) "To _Front", 3000 },
  244.     { (STRPTR) "Do you really want to close screen\n"\
  245.     "\"%s\"?", 3001 },
  246.     { (STRPTR) "Do you really want to close window\n"\
  247.     "\"%s\"?", 3002 },
  248.     { (STRPTR) "Neither SaferPatches nor SetMan nor PatchControl is installed!", 3100 },
  249.     { (STRPTR) "Wrong SetMan version!\n"\
  250.     "wanted: 0x%08lx, is: 0x%08lx", 3101 },
  251.     { (STRPTR) "Disabling patches, even a complete patch list of\n"\
  252.     "related patches, is a potentially dangerous operation.\n"\
  253.     "Are you sure you want to continue?", 3102 },
  254.     { (STRPTR) "disabled", 3103 },
  255.     { (STRPTR) "removed", 3104 },
  256.     { (STRPTR) "active", 3105 },
  257.     { (STRPTR) "Can't open %s version %ld!", 3200 },
  258.     { (STRPTR) "Do you really want to remove reset handler\n"\
  259.     "\"%s\"?", 3300 }
  260. };
  261.  
  262. STATIC struct Catalog *ScoutCatalog = NULL;
  263. #ifdef LOCALIZE_V20
  264. STATIC STRPTR ScoutStrings = NULL;
  265. STATIC ULONG ScoutStringsSize;
  266. #endif
  267.  
  268.  
  269. VOID CloseScoutCatalog(VOID)
  270.  
  271. {
  272.     if (ScoutCatalog) {
  273.     CloseCatalog(ScoutCatalog);
  274.     }
  275. #ifdef LOCALIZE_V20
  276.     if (ScoutStrings) {
  277.     FreeMem(ScoutStrings, ScoutStringsSize);
  278.     }
  279. #endif
  280. }
  281.  
  282.  
  283. VOID OpenScoutCatalog(VOID)
  284. {
  285.     if (LocaleBase) {
  286.     if ((ScoutCatalog = OpenCatalog(NULL, (STRPTR) "Scout.catalog",
  287.                      OC_BuiltInLanguage, "english",
  288.                      OC_Version, 3,
  289.                      TAG_DONE))) {
  290.         struct FC_String *fc;
  291.         int i;
  292.  
  293.         for (i = 0, fc = Scout_Strings;  i < 171;  i++, fc++) {
  294.          fc->msg = GetCatalogStr(ScoutCatalog, fc->id, (STRPTR) fc->msg);
  295.         }
  296.     }
  297.     }
  298. }
  299.  
  300. #if defined(__GNUC__)
  301. __asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpenScoutCatalog");
  302. __asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDCloseScoutCatalog");
  303. #endif
  304.  
  305.  
  306.  
  307. #ifdef LOCALIZE_V20
  308. VOID InitScoutCatalog(STRPTR language)
  309.  
  310. {
  311.     struct IFFHandle *iffHandle;
  312.  
  313.     /*
  314.     **  Use iffparse.library only, if we need to.
  315.     */
  316.     if (LocaleBase  ||  !IFFParseBase  ||  !language  ||
  317.     Stricmp(language, "english") == 0) {
  318.     return;
  319.     }
  320.  
  321.     if ((iffHandle = AllocIFF())) {
  322.     char path[128]; /* Enough to hold 4 path items (dos.library 3.1)    */
  323.     strcpy(path, "PROGDIR:Catalogs");
  324.     AddPart((STRPTR) path, language, sizeof(path));
  325.     AddPart((STRPTR) path, "Scout.catalog", sizeof(path));
  326.     if (!(iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE))) {
  327.         strcpy(path, "LOCALE:Catalogs");
  328.         AddPart((STRPTR) path, language, sizeof(path));
  329.         AddPart((STRPTR) path, language, sizeof(path));
  330.         iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE);
  331.     }
  332.  
  333.     if (iffHandle->iff_Stream) {
  334.         InitIFFasDOS(iffHandle);
  335.         if (!OpenIFF(iffHandle, IFFF_READ)) {
  336.         if (!PropChunk(iffHandle, MAKE_ID('C','T','L','G'),
  337.                    MAKE_ID('S','T','R','S'))) {
  338.             struct StoredProperty *sp;
  339.             int error;
  340.  
  341.             for (;;) {
  342.             if ((error = ParseIFF(iffHandle, IFFPARSE_STEP))
  343.                    ==  IFFERR_EOC) {
  344.                 continue;
  345.             }
  346.             if (error) {
  347.                 break;
  348.             }
  349.  
  350.             if ((sp = FindProp(iffHandle, MAKE_ID('C','T','L','G'),
  351.                        MAKE_ID('S','T','R','S')))) {
  352.                 /*
  353.                 **  Check catalog and calculate the needed
  354.                 **  number of bytes.
  355.                 **  A catalog string consists of
  356.                 **      ID (LONG)
  357.                 **      Size (LONG)
  358.                 **      Bytes (long word padded)
  359.                 */
  360.                 LONG bytesRemaining;
  361.                 LONG *ptr;
  362.  
  363.                 ScoutStringsSize = 0;
  364.                 bytesRemaining = sp->sp_Size;
  365.                 ptr = (LONG *) sp->sp_Data;
  366.  
  367.                 while (bytesRemaining > 0) {
  368.                 LONG skipSize, stringSize;
  369.  
  370.                 ptr++;                  /*  Skip ID     */
  371.                 stringSize = *ptr++;
  372.                 skipSize = ((stringSize+3) >> 2);
  373.  
  374.                 ScoutStringsSize += stringSize+1;  /*  NUL */
  375.                 bytesRemaining -= 8 + (skipSize << 2);
  376.                 ptr += skipSize;
  377.                 }
  378.  
  379.                 if (!bytesRemaining  &&
  380.                 (ScoutStrings = AllocMem(ScoutStringsSize, MEMF_ANY))) {
  381.                 STRPTR sptr;
  382.  
  383.                 bytesRemaining = sp->sp_Size;
  384.                 ptr = (LONG *) sp->sp_Data;
  385.                 sptr = ScoutStrings;
  386.  
  387.                 while (bytesRemaining) {
  388.                     LONG skipSize, stringSize, id;
  389.                     struct FC_String *fc;
  390.                     int i;
  391.  
  392.                     id = *ptr++;
  393.                     stringSize = *ptr++;
  394.                     skipSize = ((stringSize+3) >> 2);
  395.  
  396.                     CopyMem(ptr, sptr, stringSize);
  397.                     bytesRemaining -= 8 + (skipSize << 2);
  398.                     ptr += skipSize;
  399.  
  400.                     for (i = 0, fc = Scout_Strings;  i < 171;  i++, fc++) {
  401.                     if (fc->id == id) {
  402.                         fc->msg = sptr;
  403.                     }
  404.                     }
  405.  
  406.                     sptr += stringSize;
  407.                     *sptr++ = '\0';
  408.                 }
  409.                 }
  410.                 break;
  411.             }
  412.             }
  413.         }
  414.         CloseIFF(iffHandle);
  415.         }
  416.         Close(iffHandle->iff_Stream);
  417.     }
  418.     FreeIFF(iffHandle);
  419.     }
  420. }
  421. #endif
  422.